##########################################################################
# File Name: mouse-create-st.sh  鼠标选画终端窗口脚本
# Author: Dimerbone
# mail: 15857404828@163.com
# Created Time: 2021年02月11日 星期四
# 依赖
# sudo pacman -S slop
# > slop（Select Operation）是一个应用程序，它从用户那里查询选择并将区域打印到stdout
#########################################################################
#!/bin/zsh
#!/usr/bin/env bash
# 获取鼠标选择区域标准输入值
#slop -f "%x %y %w %h" -b 1 -t 0 -q >> debug.log
read -r X Y W H < <(slop -f "%x %y %w %h" -b 1 -t 0 -q)
# Width and Height in px need to be converted to columns/rows
# To get these magic values, make a fullscreen st, and divide your screen width by ${tput cols}, height by ${tput lines} 
(( W /= 8 ))
(( H /= 16 ))
g=${W}x${H}+${X}+${Y}
# 设置i3桌面模式为悬浮模式
# 在i3设置 类别为mouse-st的窗口为悬浮 for_window [class="mouse-st"] floating enable
# 设置bspcwm桌面模式为悬浮模式
#bspcwm rule -a st-256color -o state=floating
if [ "$1" == "perl6" ]; then
    st -c "mouse-st" -g $g -e perl6 
else
    st -c "mouse-st" -g $g  
fi

# > 鼠标选画终端脚本 github地址](https://github.com/f0x52/dots/blob/master/bin/bin/select_st)
